package com.ruoyi.project.warehouseSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.warehouseSystem.domain.COutwarehouse;
import com.ruoyi.project.warehouseSystem.service.ICOutwarehouseService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 出库申请提交Controller
 * 
 * @author wangshuo
 * @date 2021-07-18
 */
@RestController
@RequestMapping("/warehouseSystem/ckapplay")
public class COutwarehouseController extends BaseController
{
    @Autowired
    private ICOutwarehouseService cOutwarehouseService;

    /**
     * 查询出库申请提交列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:ckapplay:list')")
    @GetMapping("/list")
    public TableDataInfo list(COutwarehouse cOutwarehouse)
    {
        startPage();
        List<COutwarehouse> list = cOutwarehouseService.selectCOutwarehouseList(cOutwarehouse);
        return getDataTable(list);
    }

    /**
     * 导出出库申请提交列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:ckapplay:export')")
    @Log(title = "出库申请提交", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(COutwarehouse cOutwarehouse)
    {
        List<COutwarehouse> list = cOutwarehouseService.selectCOutwarehouseList(cOutwarehouse);
        ExcelUtil<COutwarehouse> util = new ExcelUtil<COutwarehouse>(COutwarehouse.class);
        return util.exportExcel(list, "ckapplay");
    }

    /**
     * 获取出库申请提交详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:ckapplay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(cOutwarehouseService.selectCOutwarehouseById(id));
    }

    /**
     * 新增出库申请提交
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:ckapplay:add')")
    @Log(title = "出库申请提交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody COutwarehouse cOutwarehouse)
    {
        return toAjax(cOutwarehouseService.insertCOutwarehouse(cOutwarehouse));
    }

    /**
     * 修改出库申请提交
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:ckapplay:edit')")
    @Log(title = "出库申请提交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody COutwarehouse cOutwarehouse)
    {
        return toAjax(cOutwarehouseService.updateCOutwarehouse(cOutwarehouse));
    }

    /**
     * 删除出库申请提交
     */
    @PreAuthorize("@ss.hasPermi('warehouseSystem:ckapplay:remove')")
    @Log(title = "出库申请提交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cOutwarehouseService.deleteCOutwarehouseByIds(ids));
    }
}
